

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Busqueda
 */
public class Busqueda extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Busqueda() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter salida = response.getWriter();
		response.setContentType("text/html");
		String tipo = request.getParameter("Tipo");
		String local = request.getParameter("Localizacion");
		String precio = request.getParameter("Precio");
		
		propiedad np = new propiedad();
		np.setTipoprop(tipo.toUpperCase());
		np.setDireccion(local.toUpperCase());
		np.setPrecio(precio.toUpperCase());

		ArrayList<propiedad> lista1 = new ArrayList<propiedad>();
		  try {
			  PropDAO PD = new PropDAO();
			  lista1 = PD.listarTipo(np);
		  } catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			  e.printStackTrace();	
		  } catch (SQLException e) {
			// TODO Auto-generated catch block
			  e.printStackTrace();
		  }
		  Iterator<propiedad> itr = lista1.iterator();
		  while (itr.hasNext()) {
			  propiedad element = itr.next();
			  salida.println("<p>TIPO : "+ element.getTipoprop() + " <br>");
			  salida.println("Localizacion : " + element.getDireccion() + " <br>");
			  salida.println("Precio : " + element.getPrecio() + "  </p><br>");
		  }
	}

}
//campo null si quiero vacio
